# for i in range(0,4): #控制行数
#     for j in range(0,i+1):  #控制每行中的空格数
#         print(" ",end=" ")
#     for j in range(0,4): #控制每行中的#数
#         print("#",end=" ")
#     print() #控制换行



# for n in range(200,1,-1):
#     if n%2==0 and n!=2:
#         continue
#     for i in range(3,int(n**0.5)+1,2):
#         if n%i == 0:
#             break
#     else:
#         print(n)
#         break


# number = int(input("请输入一个正整数"))
# a,b = 1,1
# while a < number:
#     print(a,end=" ")
#     a, b = b , a+b


try:
    year = int(input('输入年:'))
    assert year > 0
    #定义每个月的天数列表day_month
    day_month = [31,28,31,30,31,30,31,31,30,31,30,31]
    month = int(input('输入月:'))
    day = int(input('输入日:'))
    #如果今年是闰年，把二月改为29天
    if year % 400 == 0 or ( year % 4 == 0 and year % 100 != 0): #判断是否为闰年
        day_month[1] = 29
        assert 1 <= day <= day_month[month - 1]
except:
    print('输入错误')
else:
    if month == 1:
        print(day)
    else:
        print(sum(day_month[:month - 1]) + day)



# try:
#     m = int(input('请输入鸡和兔的总数：'))
#     n = int(input('请输入笼子里腿：'))
# except:
#     print('两个数字必须是整数')
# else:
#     y = (n - 2 * m )/2
#     x = m - y
#     if y ==int(y) and y > 0 and x > 0:
#         print(f'鸡{x}只,兔{y}只。')
#     else:
#         print('数据错误，无解。')

















